<?php
/**
 * (amazon-model) Amazon订单配置 (修补订单使用)
 */
namespace App\Models\Amazon;

use App\Models\Basics\AmazonAccount;
use Illuminate\Database\Eloquent\Model;
class AmazonOrderConditionRepair extends Model
{
    protected $connection = 'mysql_amazon';

    protected $table = 'amazon_order_condition_repair';

    protected $guarded  = [];

    public function account(){
        return $this->belongsTo(AmazonAccount::class,'account_id');
    }

    public static function getNextStartTime($accountId){
        $re = self::query()->where('account_id',$accountId)->value('next_start_time');
        return $re ? getDateFormat($re) : '';
    }

    public static function upNextStartTime($accountId,$lastUpdatedBefore){
        $obj = self::query()->where('account_id',$accountId)->first();
        $obj->next_start_time = gmdate('Y-m-d H:i:s',strtotime($lastUpdatedBefore));
        $obj->save();
    }

}
